<?php

abstract class AbstractSingleton {

    protected function __construct() {}
    protected function __clone() { throw new Exception('Cannot clone singleton'); }

    private static $hInstances = array();

    abstract protected static function getInstance();

    protected static function doGetInstance($className) {

        if (!isset(self::$hInstances[$className]))
            self::$hInstances[$className] = new $className;

        return self::$hInstances[$className];
    }
}

?>